package com.swpu.eduStatistics.controller;


import com.swpu.commonutils.R;
import com.swpu.eduStatistics.Client.UcenterClient;
import com.swpu.eduStatistics.service.StatisticsDailyService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author ygq
 * @since 2021-11-01
 */

@RestController
@RequestMapping("/eduStatistics/daily")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService service;

    //统计一天中的注册人数
    @PostMapping("registerCount/{day}")
    public R getRegisterCount(@PathVariable String day){
        service.createStatisticsByDay(day);
        return R.ok();
    }

    @GetMapping("show-chart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = service.getChartData(begin, end, type);
        return R.ok().data(map);
    }

}

